//Home模块的小仓库
import { reqCategoryList,reqGetBannerList,reqGetFloorList } from "@/api"
// actions 处理异步，接受服务器端的数据
const actions = {
    // 通过APi接口函数调用，向服务器发请求，获取数据
    async categoryList(context,value){
        let result = await reqCategoryList()
        // console.log(result)
        if(result.code==200){
            context.commit('CATEGORYLIST',result.data)
        }
    },
    async getBannerList(context,value){
        let result = await reqGetBannerList()
        // console.log(result)
        if(result.code==200){
            context.commit('BANNERLIST',result.data)
        }
    },
    async getFloorList(context,value){
        let result = await reqGetFloorList()
        // console.log(result)
        if(result.code==200){
            context.commit('FLOORLIST',result.data)
        }
    }
}
//mutations 修改state的唯一方法
const mutations = {
    CATEGORYLIST(state,categoryList){
         state.categoryList = categoryList
    },
    BANNERLIST(state,getBannerList){
        state.getBannerList = getBannerList
    },
    FLOORLIST(state,getFloorList){
        state.getFloorList = getFloorList
    }
}
//state仓库存储数据
const state = {
    categoryList:[],
    getBannerList:[],
    getFloorList:[]
}
// getters 计算属性，组件获取仓库的数据更加方便
const getters = {}

export default {
    state,
    actions,
    mutations,
    getters,
  };

